package edu.scau.pro.hotel.service.impl;

import edu.scau.pro.hotel.entity.HotelReserve;
import edu.scau.pro.hotel.mapper.HotelReserveMapper;
import edu.scau.pro.hotel.service.IHotelReserveService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (HotelReserve)表服务实现类
 *
 * @author CJW
 * @since 2022-03-13 11:44:44
 */
@Service("hotelReserveService")
public class HotelReserveServiceImpl implements IHotelReserveService {
    @Resource
    private HotelReserveMapper hotelReserveMapper;

    /**
     * 通过ID查询单条数据
     *
     * @param reserveId 主键
     * @return 实例对象
     */
    @Override
    public HotelReserve queryById(Integer reserveId) {
        return this.hotelReserveMapper.queryById(reserveId);
    }

    /**
     * 查询指定行
     *
     * @param hotelReserve 筛选条件
     * @return 查询结果
     */
    @Override
    public List<HotelReserve> queryAll(HotelReserve hotelReserve) {
        return this.hotelReserveMapper.queryAll(hotelReserve);
    }

    /**
     * 新增数据
     *
     * @param hotelReserve 实例对象
     * @return 实例对象
     */
    @Override
    public HotelReserve insert(HotelReserve hotelReserve) {
        this.hotelReserveMapper.insert(hotelReserve);
        return hotelReserve;
    }

    /**
     * 修改数据
     *
     * @param hotelReserve 实例对象
     * @return 实例对象
     */
    @Override
    public HotelReserve update(HotelReserve hotelReserve) {
        this.hotelReserveMapper.update(hotelReserve);
        return this.queryById(hotelReserve.getReserveId());
    }

    /**
     * 通过主键删除数据
     *
     * @param reserveId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer reserveId) {
        return this.hotelReserveMapper.deleteById(reserveId) > 0;
    }
}
